package com.hy.frame.base;

import android.content.pm.ActivityInfo;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.hy.frame.common.ILifeUI;

/**
 * title BaseActivity
 * author HeYan
 * time 2021/2/1 13:36
 * desc 无
 */
public abstract class BaseActivity extends SuperActivity implements ILifeUI {

    private Bundle mArgs = null;
    private boolean mDestroy;
    private boolean mPause;
    private boolean mStop;
    private boolean mResume;

    /**
     * 屏幕方向
     */
    public int getScreenOrientation() {
        return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }

    @Nullable
    protected Bundle getArgs() {
        if (this.mArgs == null) {
            this.mArgs = getIntent().getExtras();
        }
        return this.mArgs;
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    @Override
    protected void initWindow() {
        if (getScreenOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
            setRequestedOrientation(getScreenOrientation());
        }
    }

    @Override
    protected boolean initAttrs() {
        return true;
    }

    @Override
    protected void onResume() {
        super.onResume();
        this.mPause = false;
        this.mStop = false;
        this.mResume = true;
    }

    @Override
    protected void onPause() {
        super.onPause();
        this.mPause = true;
        this.mResume = false;
    }

    @Override
    protected void onStop() {
        super.onStop();
        this.mStop = true;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.mDestroy = true;
    }

    /**
     * 是否已经销毁
     */
    @Override
    public boolean isIDestroy() {
        return mDestroy;
    }

    /**
     * 是否已经暂停
     */
    @Override
    public boolean isIPause() {
        return mPause;
    }

    /**
     * 是否已经停止
     */
    @Override
    public boolean isIStop() {
        return mStop;
    }

    /**
     * 是否已经恢复
     */
    @Override
    public boolean isIResume() {
        return mResume;
    }
}
